package com.ruoyi.web.controller.ring;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.ring.domain.RingExerciseDetail;
import com.ruoyi.ring.service.IRingExerciseDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 锻炼详情Controller
 * 
 * @author liuwp
 * @date 2025-09-25
 */
@RestController
@RequestMapping("/ring/ring_exercise_detail")
public class RingExerciseDetailController extends BaseController
{
    @Autowired
    private IRingExerciseDetailService ringExerciseDetailService;

    /**
     * 查询锻炼详情列表
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_exercise_detail:list')")
    @GetMapping("/list")
    public TableDataInfo list(RingExerciseDetail ringExerciseDetail)
    {
        startPage();
        List<RingExerciseDetail> list = ringExerciseDetailService.selectRingExerciseDetailList(ringExerciseDetail);
        return getDataTable(list);
    }

    /**
     * 导出锻炼详情列表
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_exercise_detail:export')")
    @Log(title = "锻炼详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RingExerciseDetail ringExerciseDetail)
    {
        List<RingExerciseDetail> list = ringExerciseDetailService.selectRingExerciseDetailList(ringExerciseDetail);
        ExcelUtil<RingExerciseDetail> util = new ExcelUtil<RingExerciseDetail>(RingExerciseDetail.class);
        util.exportExcel(response, list, "锻炼详情数据");
    }

    /**
     * 获取锻炼详情详细信息
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_exercise_detail:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(ringExerciseDetailService.selectRingExerciseDetailById(id));
    }

    /**
     * 新增锻炼详情
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_exercise_detail:add')")
    @Log(title = "锻炼详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RingExerciseDetail ringExerciseDetail)
    {
        return toAjax(ringExerciseDetailService.insertRingExerciseDetail(ringExerciseDetail));
    }

    /**
     * 修改锻炼详情
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_exercise_detail:edit')")
    @Log(title = "锻炼详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RingExerciseDetail ringExerciseDetail)
    {
        return toAjax(ringExerciseDetailService.updateRingExerciseDetail(ringExerciseDetail));
    }

    /**
     * 删除锻炼详情
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_exercise_detail:remove')")
    @Log(title = "锻炼详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ringExerciseDetailService.deleteRingExerciseDetailByIds(ids));
    }
}
